''' 索引切片重写 '''

class Mynumber():
    def __init__(self,data=[]):
        self.data = data

    def __repr__(self):
        return "运算符重写：%d" % self.data

    def __getitem__(self, item):
        return  self.data[item]

    def __setitem__(self, key, value):
        self.data[key] = value

    def __delitem__(self, key):
        del self.data[key]


L = [1,2,3]
print(L)
print(L[2])

# 如果没有重写，自己定义的类将无法使用内建函数
my_l = Mynumber([11,22,33,44,55,66,77,88,99])
print(my_l[2])
print(my_l[0:3])
print(my_l[::-1])
my_l[0] = 888
print(my_l[0])
del my_l[0]
print(my_l[::])

my_l[0:4] = [0,0]
print(my_l.data)